﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StringDefs.Tests
{
    using NUnit.Framework;
    using StringDefs.SourceCode;

    [TestFixture]
    public class SourceCodeTests
    {
        string validCPPComment = "//int a=10;";
        string invalidCPPComment = "int a=10;";
        string validCComment = "/*int a=10;*/";


        [Test]
        public void MakeCComment_Statement_ReturnsCommentedLine()
        {
            Assert.AreEqual("/*int a=10;*/", "int a=10;".MakeCComment());
        }

        [Test]
        public void isCPPComment_Valid_ReturnsTrue()
        {
            Assert.True(validCPPComment.isCPPComment());
        }

        [Test]
        public void IsJavaComment_Valid_ReturnsTrue()
        {
            Assert.True(validCPPComment.isJavaComment());
        }

        [Test]
        public void isCPPComment_Invalid_ReturnsFalse()
        {
            Assert.False(invalidCPPComment.isCPPComment());
        }

        [Test]
        public void IsJavaComment_Invalid_ReturnsFalse()
        {
            Assert.False(invalidCPPComment.isJavaComment());
        }

        [Test]
        public void IsCComment_Valid_ReturnsTrue()
        {
            Assert.True(validCComment.IsCComment());
        }

        [Test]
        public void IsCComment_Invalid_ReturnsFalse()
        {
            string invalidCComment = "/*int a=10;";
            Assert.False(invalidCComment.IsCComment());
        }

        [Test]
        public void isVBComment_Valid_ReturnsTrue()
        {
            string validVBComment = "'This is a vb commented line";
            Assert.True(validVBComment.isVBComment());
        }

        [Test]
        public void isVBComment_Invalid_ReturnsFalse()
        {
            Assert.False(invalidCPPComment.isVBComment());
        }

        [Test]
        public void IsValidIdentifier_Valid_ReturnsTrue()
        {
            string[] validIdentifiers = { "balance", "isValidString", "VB", "temp3" };
            foreach (string identifier in validIdentifiers)
            {
                Assert.True(identifier.IsValidIdentifier());
            }
        }

        [Test]
        public void IsValidIdentifier_Invalid_ReturnsFalse()
        {
            string invalidIdentifier = "!ant";
            Assert.False(invalidIdentifier.IsValidIdentifier());
        }
    }
}
